import axiosInstance from "./axios";

//登录
export const login = (data: any) =>
    axiosInstance.post('/login', data)

//获取个人信息
export const getInfo = (params: any) =>
    axiosInstance.get('/userInfo', { params })

//用户修改个人信息
export const editUserInfo = (data: any) =>
    axiosInstance.put('/userInfo', data)

//上传头像
export const uploadAvatar = (data: any) =>
    axiosInstance.post('/uploadavatar', data, {
        headers: {
            'Content-Type': 'multipart/form-data',
        }
    })

//修改密码
export const editPwd = (data: any) =>
    axiosInstance.put('/userPwd', data)

/**
 * 首页
 */
export const getLoginDiary = (params: any) =>
    axiosInstance.get('/home/loginDiary', { params })

export const getNums = () =>
    axiosInstance.get('/home/nums')

export const getOrderPercents = () =>
    axiosInstance.get('/home/orderPercents')

export const getProducePercents = () =>
    axiosInstance.get('/home/producePercents')

export const getBuyPercents = () =>
    axiosInstance.get('/home/buyPercents')



/**
 * 权限管理模块
 */

//获取角色列表
export const getRole = (params: any) =>
    axiosInstance.get('/supermanage/role', { params })

//添加角色
export const addRole = (data: any) =>
    axiosInstance.post('/supermanage/role', data)

//删除角色
export const deleteRole = (params: any) =>
    axiosInstance.delete('/supermanage/role', { data: params })

//编辑角色
export const editRole = (data: any) =>
    axiosInstance.put('/supermanage/role', data)

//获取所有权限
export const getLimits = () =>
    axiosInstance.get('/supermanage/limits')

//获取角色权限
export const getRoleLimits = (params: any) =>
    axiosInstance.get('/supermanage/rolelimits', { params })

//获取角色权限
export const setRoleLimits = (data: any) =>
    axiosInstance.put('/supermanage/rolelimits', data)

//获取用户列表
export const getUser = (params: any) =>
    axiosInstance.get('/supermanage/users', { params })


//添加用户
export const addUser = (data: any) =>
    axiosInstance.post('/supermanage/users', data)

//编辑用户
export const editUser = (data: any) =>
    axiosInstance.put('/supermanage/users', data)

//删除用户
export const deleteUser = (params: any) =>
    axiosInstance.delete('/supermanage/users', { data: params })

//获取用户权限
export const getUserLimits = (params: any) =>
    axiosInstance.get('/supermanage/userlimits', { params })



/**
 * 订单模块 
 * 
 */
//订单列表
export const getOrder = (params: any) =>
    axiosInstance.get('/order', { params })


//添加订单
export const addOrder = (data: any) =>
    axiosInstance.post('/order', data)

//编辑订单
export const editOrder = (data: any) =>
    axiosInstance.put('/order', data);

//删除订单
export const deleteOrder = (params: any) =>
    axiosInstance.delete('/order', { data: params })

//生产计划员列表
export const getPlanner = () =>
    axiosInstance.get('/order/planners')

//获取货物列表
export const getProduct = () =>
    axiosInstance.get('/order/goods')

//委派订单
export const distributionOrder = (data: any) =>
    axiosInstance.post('/order/distribution', data)

//合作公司列表
export const getCompany = () =>
    axiosInstance.get('/order/company')

//获取经理列表
export const getDirectors = () =>
    axiosInstance.get('/order/directors')

//产品提库申请
export const outRequire = (data: any) =>
    axiosInstance.post('/order/outRequire', data)

/**
 * 生产模块
 * 
 */

//获取生产订单列表
export const getProduce = (params: any) =>
    axiosInstance.get('/produce', { params })

//修改生产订单
export const editProduce = (data: any) =>
    axiosInstance.put('/produce', data);

//获取车间生产员列表
export const getProducers = () =>
    axiosInstance.get('/produce/producers')


//委派生产订单
export const distributionProduce = (data: any) =>
    axiosInstance.post('/produce/distribution', data)


//获取原材料
export const getMaterial = () =>
    axiosInstance.get('/produce/goods')

//原料提库申请
export const outMaterialRequire = (data: any) =>
    axiosInstance.post('/produce/outRequire', data)

//产品入库申请
export const inProduceRequire = (data: any) =>
    axiosInstance.post('/produce/inRequire', data)

/**
 * 采购模块
 */

//采购列表
export const getBuy = (params: any) =>
    axiosInstance.get('/buy', { params })

//新增采购订单
export const addBuy = (data: any) =>
    axiosInstance.post('/buy', data)

//采购员列表
export const getBuyers = () =>
    axiosInstance.get('/buy/buyers')

//采购员列表
export const getStorers = () =>
    axiosInstance.get('/buy/storers')

//委派采购订单
export const distributionBuy = (data: any) =>
    axiosInstance.post('/buy/distribution', data)

//原料入库申请
export const inMaterialRequire = (data: any) =>
    axiosInstance.post('/buy/inRequire', data)

//删除采购订单
export const deleteBuy = (params: any) =>
    axiosInstance.delete('/buy', { data: params })




/**
 * 仓库模块
 * 
 */

//仓库列表
export const getGoods = (params: any) =>
    axiosInstance.get('/goods', { params })

//新增产品
export const addGoods = (data: any,) =>
    axiosInstance.post('/goods', data, {
        headers: {
            'Content-Type': 'multipart/form-data',
        },
    });
//编辑产品
export const editGoods = (data: any) =>
    axiosInstance.put('/goods', data);

//删除产品
export const deleteGoods = (params: any) =>
    axiosInstance.delete('/goods', { data: params })

//获取仓库请求
export const getRequire = (params: any) =>
    axiosInstance.get('/goods/require', { params })

//批准入库
export const agreeInRequire = (data: any) =>
    axiosInstance.post('/goods/inRequire', data)

//批准入库
export const agreeOutRequire = (data: any) =>
    axiosInstance.post('/goods/outRequire', data)


/**
 * 客户模块
 */

//客户列表
export const getCustomer = (params: any) =>
    axiosInstance.get('/customer', { params })

//新增客户
export const addCustomer = (data: any,) =>
    axiosInstance.post('/customer', data);

//编辑客户
export const editCustomer = (data: any) =>
    axiosInstance.put('/customer', data);

//删除客户
export const delCustomer = (params: any) =>
    axiosInstance.delete('/customer', { params });

//搜索客户
export const searchCustomer = (params: any) =>
    axiosInstance.get('/customer/searchCustomer', { params })

/**
 * 财务管理模块
 */

export const getFinance = (params: any) =>
    axiosInstance.get('/finance', { params })

export const getFinanceLine = (params: any) =>
    axiosInstance.get('/finance/financeLine', { params })

